<template>
    <div>
        <h1>会员等级添加</h1>
      <table class="table">
         <tbody>
            <tr>
            <td>权益名称</td>
            <td>
                <input type="text" v-model="data.quanyiName">
            </td>
        </tr> 
        <tr>
            <td>状态</td>
            <td> <input type="checkbox" v-model="data.qstate" checked>选择为启用,未选择未禁用</td>
        </tr>
        <tr>
            <td colspan="2"><input type="button" value="添加会员权益" @click="add"></td>
        </tr>
         </tbody>
      </table>
        
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios';
import { useRouter } from 'vue-router';
 

const router=useRouter();

const data = ref({
    "id": 0,
  "quanyiName": "",
  "qstate": true
})
  
const add=()=>{ 

    axios.post("https://localhost:7065/api/Quanyi/AddQuan",data.value).then(res=>{
          if(res.data>0)
          {
              alert("会员权益添加成功");
              router.push({path:"/qshow"})
          } 
          else if(res.data==-1)
          {
             alert("会员权益名称重复")
             return;
          }
          else{
            alert("会员权益添加失败");
            return;
          }
    })
}

</script>

<style scoped>

</style>